home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: Default values for constructor arguments
- Date: 7 Mar 1996 19:08:03 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Message-ID: <4hnc6j$mgj@dawn.mmm.com>
- References: <4hjoof$5qk@newnews.iafrica.com>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Peter Golda (goldap@telkom11.telkom.co.za) wrote:
- > Hi,
-
- > I had a constructor for my MWMessageLog class as follows:
-
- > MWMessageLog(
- > const RWCString& anExecutableCode,
- > const RWCString& aSystemCode,
- > const RWCString& aLogFilePath );
-
- > where the class RWCString comes from the Rogue Wave development library
- > and is just a simple string class.
-
- > Now, I wanted to add default values, so I wrote as follows (knowing that
- > RWCString has a constructor that constructs RWCString from char* and it
- > has an assignment operator):
-
- > MWMessageLog(
- > ...
- > ...
- > const RWCString& aLogFilePath = "~/logs/" );
-
- > but now the compiler moans that it doesn't like that since the default
- > value must be passed through a constructor.
-
- It works with SunSoft C++ 4.1. You might try
- MWMessageLog(
- ...
- const RWCString& aLogFilePath = RWCString("~/logs/"));
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-